package reflect;

import java.lang.reflect.Method;

/**
 * @Classname: ReflectDemo6
 * @Author: bromide
 * @CreateTime: 2022/4/18--15:33
 * @Version: V1.0
 * @Description:
 */
public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        Method[] methods = cls.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println(method.getName());
        }
        Method method = cls.getDeclaredMethod("dosome");
        method.setAccessible(true);//强行打开dosome方法的访问权限
        method.invoke(obj);
    }
}
